package layers.ants;

import java.util.ArrayList;

import layers.agents.AgentInterface;
import layers.physical.Crossroad;
import layers.physical.Path;

public abstract class HopAnt extends PathAnt {
	private final int initialHops;
	private int remainingHops;
	
	public HopAnt(Crossroad crossroad, AgentInterface agent, Path path, int amountOfHops, long traveledDistance) {
		super(crossroad, agent, path);
		if(traveledDistance < 0)
			throw new IllegalArgumentException("Traveled distance must be positive.");
		if(amountOfHops < 0)
			throw new IllegalArgumentException("Amount of hops must be positive.");
		this.setTraveledDistance(traveledDistance);
		this.initialHops = amountOfHops;
		this.remainingHops = amountOfHops;
		completePath(crossroad);
	}

	private void completePath(Crossroad crossroad) {
		if(this.getPath() == null){
			ArrayList<Crossroad> np = new ArrayList<Crossroad>();
			np.add(crossroad);
			this.setPath(new Path(np));
		}else
			this.getPath().addCrossroadToPath(crossroad);
	}

	protected int getRemainingHops() {
		return this.remainingHops;
	}

	protected int getInitialHops() {
		return initialHops;
	}

	protected void decreaseRemainingHops() {
		this.remainingHops--;
	}
}
